#include <iostream>
#include <string>
#include <map>

class GameAccount {
private:
    int playerID;
    std::string accountName;
    std::map<int, int> gameInventory; // 游戏编码和库存数量的映射

public:
    // 构造函数，初始化玩家ID，账号名称
    GameAccount(int id, const std::string& name) : playerID(id), accountName(name) {}

    // 打印玩家ID、账号和游戏库存数量
    void printAccountInfo() const {
        std::cout << "Player ID: " << playerID << "\nAccount Name: " << accountName
                  << "\nGame Inventory Size: " << gameInventory.size() << std::endl;
    }

    // 存入指定编码的游戏
    void addGame(int gameCode) {
        gameInventory[gameCode]++;
        std::cout << "Added game with code: " << gameCode << "\n";
    }

    // 删除指定编码的游戏
    void removeGame(int gameCode) {
        auto it = gameInventory.find(gameCode);
        if (it != gameInventory.end()) {
            if (it->second > 1) {
                it->second--;  // 库存大于1时减少数量
            } else {
                gameInventory.erase(it);  // 库存为1时删除游戏
            }
            std::cout << "Removed game with code: " << gameCode << "\n";
        } else {
            std::cout << "Game with code " << gameCode << " not found in inventory.\n";
        }
    }
};

int main() {
    GameAccount account(1, "PlayerOne");

    account.printAccountInfo();
    account.addGame(101);
    account.addGame(102);
    account.printAccountInfo();
    account.removeGame(101);
    account.printAccountInfo();
    account.removeGame(999);  // 删除不存在的游戏

    return 0;
}
